# -*- coding: utf-8 -*-
from sqlalchemy import Column,String,Integer,Text,Binary,Boolean,DateTime,Enum,Float,BigInteger
from adminApp.extensions import db
from .base import BaseModel
import uuid


def gen_id():
    return uuid.uuid4().hex


class DefaultNicFlowData(BaseModel, db.Model):
    '''设备默认路由网卡流量数据'''
    bytes_sent = Column(BigInteger)
    bytes_recv = Column(BigInteger)
    packets_sent = Column(BigInteger)
    packets_recv = Column(BigInteger)
    errin = Column(Integer)
    errout = Column(Integer)
    dropin = Column(Integer)
    dropout = Column(Integer)
    ten_bt_sent = Column(BigInteger)  # 与上次时间记录的量差 发送字节数 10分钟
    ten_bt_recv = Column(BigInteger)
    ten_pk_sent = Column(BigInteger)
    ten_pk_recv = Column(BigInteger)
    flow_datetime = Column(DateTime, nullable=False)

    machine_id = db.Column(db.Integer, db.ForeignKey('machine.id', ondelete='CASCADE'), nullable=False, index=True)
    machine = db.relationship('Machine', back_populates='defaultNicFlowDatas')